from api.organization import OrganizationAPI
from api.login import Loginapi
from  public1.dbutil import DBUtil
from public1.public_assert import assert_success

# 创建测试类
class TestOrganization:
    token666=None
    id666=None
    def setup_class(self):
        response=Loginapi().login()
        TestOrganization.token666=response.json().get("data")
        print(TestOrganization.token666)

    def test01_addDepartment(self):
        body_data={
            "name":"孙军乐",
            "code":"孙军乐"
        }
        response = OrganizationAPI().addDepartment(TestOrganization.token666,body_data)
        print(response.json())
        assert_success(response)
        TestOrganization.id666 = response.json().get("data").get("id")
        print(TestOrganization.id666)
    def test02_queryDepartmentInformation(self):

        response = OrganizationAPI().inquiryDepartment(TestOrganization.token666,TestOrganization.id666)
        print(response.json())

        assert_success(response)

    def test03_modified(self):
        updata_department = {
            "name": "乐乐小傻瓜"
        }
        response = OrganizationAPI().modifyDepartment(TestOrganization.token666,TestOrganization.id666,updata_department)
        print(response.json())
        assert_success(response)
    def test04_del_department(self):

        response=OrganizationAPI().deleteDepartment(TestOrganization.token666,TestOrganization.id666)
        print(response.json())
        assert_success(response)